
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.webdriver import WebDriver

from appium0704.appiumpo.BasePage import BasePage


class EditMemberPage(BasePage):
    _name_element = (MobileBy.XPATH, "//*[contains(@text,'姓名')]/../android.widget.EditText")
    _phone_element = (MobileBy.XPATH, "//*[contains(@text,'手机')]/..//android.widget.EditText")
    _saveclick_element = (MobileBy.XPATH, "//*[@text='保存']")

    def edit_member(self,name,phone):
        from appium0704.appiumpo.AddMemberPage import AddMemberPage
        self.find(*self._name_element).send_keys(name)
        self.find(*self._phone_element).send_keys(phone)
        self.find_and_click(*self._saveclick_element)
        #
        # self.driver.find_element(MobileBy.XPATH,
        #                          "//*[contains(@text,'姓名')]/../android.widget.EditText").send_keys(name)
        # self.driver.find_element(MobileBy.XPATH,
        #                          "//*[contains(@text,'手机')]/..//android.widget.EditText").send_keys(phone)
        # self.driver.find_element(MobileBy.XPATH, "//*[@text='保存']").click()

        return AddMemberPage(self.driver)
